package com.ushine.design.design.c_behavioral_pattern.g_observer.a_practice;

import java.util.ArrayList;

public abstract class Subject {
    //定义一个观察者集合
    protected ArrayList<Observer> observers = new ArrayList<>();

    //注册方法
    public void attach(Observer observer) {
        observers.add(observer);
    }

    //注销方法
    public void detach(Observer observer) {
        observers.remove(observer);
    }

    //声明通知方法
    public abstract void notifyObserver();
}
